package com.hangwei.paperless.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.hangwei.paperless.R;
import com.hangwei.paperless.model.bean.ProcessSheet;
import com.twelve.all.adapter.MyAdapter;
import com.twelve.all.utils.Tools;

import java.util.List;

public class ProcessListAdapter extends MyAdapter<ProcessSheet, BaseViewHolder> {

    public ProcessListAdapter(@Nullable List<ProcessSheet> data) {
        super(R.layout.item_prosess_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ProcessSheet item) {
        if (item.whiteBg)
            helper.itemView.setBackgroundColor(Color.WHITE);
        else helper.itemView.setBackgroundColor(Color.parseColor("#EEF6FF"));
        helper.addOnClickListener(R.id.tvProgressSheet)
             .addOnClickListener(R.id.tvCardList)
             .addOnClickListener(R.id.tvCardProcess)
             .addOnClickListener(R.id.tvCardFirstCheck)
                .setText(R.id.tvWoNo, Tools.checkedString(item.woNo))
                .setText(R.id.tvBushPN, Tools.checkedString(item.bushPN))
                .setText(R.id.tvBushIPLNo, Tools.checkedString(item.bushIPLNo))
                .setText(R.id.tvQty, Tools.checkedString(item.qty))
                .setText(R.id.tvPriority, Tools.checkedString(item.priority));
        TextView tvPriority = helper.getView(R.id.tvPriority);
        switch (item.priority){
            case 1:
                tvPriority.setBackgroundResource(R.drawable.priority_bg_1);
                break;
            case 2:
                tvPriority.setBackgroundResource(R.drawable.priority_bg_2);
                break;
            case 3:
                tvPriority.setBackgroundResource(R.drawable.priority_bg_3);
                break;
            case 4:
                tvPriority.setBackgroundResource(R.drawable.priority_bg_4);
                break;
        }
    }
}
